#!/bin/bash

# 获取当前时间并格式化为版本号（YYYYMMDDHHMMSS）
version=$(date +"%Y%m%d%H%M%S")

# 定义变量
depository="ds-content-factory"
namespaces="tenant-yfqm"
url="registry-vecps.gaccloud.com.cn"
pom="pom.xml"
vue="vue.config.js"
tag=$url/$namespaces/$depository:$version
dockerfile="Dockerfile"
user="xucongcong913671@talkweb.com.cn@57891"
password="Ty-Ai7-KDc8.3gb"

# 构建 Docker 镜像
echo "[start] build docker image"
docker build -f $dockerfile -t $depository .
echo "[end] build docker image"

# 标记镜像
echo "[start] tag image tag=" $tag
docker tag $depository $tag
echo "[end] tag image"

# 登录私有镜像仓库
#echo "[start] login to registry"
#docker login -u $user -p $password $url
#echo "[end] login to registry"

# 推送镜像
echo "[start] push tag to gaccloud"
docker push $url/$namespaces/$depository:$version
echo "[end] push tag to gaccloud"
